package com.epoint.mobileoa.personalized.epointcompany.bizlogic;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.dom4j.Element;

import android.os.Message;

import com.epoint.mobileoa.bizlogic.SuperView;
import com.epoint.mobileoa.bizlogic.Task;
import com.epoint.mobileoa.datanalysis.XMLHelp;
import com.epoint.mobileoa.http.HttpHelp;
import com.epoint.mobileoa.personalized.epointcompany.model.ChuchaiDetailListModel;
import com.epoint.mobileoa.personalized.epointcompany.model.ChuchaijihualistModel;

/**
 * @author liyc
 * @time 2012-5-3 下午4:59:12
 * @annotation 
 */
public class GetChuchaijihuadetailListTask extends Task {

	/**
	 * @param con
	 * @param param
	 */
	public GetChuchaijihuadetailListTask(SuperView con,
			HashMap<String, Object> param) {
		super(con, param);
	}

	@Override
	public void exectue(Message mess) throws Exception {
		String dateStr = getParam().get("dateStr").toString();
		String seamurl = generateURL("Epoint_GetChuchaijihuadetailList",dateStr);
		String bs = HttpHelp.getHttpBack(seamurl);
		setMessageToRefreshUI(mess, getCon(), bs);
	}
	
	public static List<ChuchaiDetailListModel> XmlAnalysis(String xml){
		List focs = XMLHelp.getRoot(xml).elements();
		List<ChuchaiDetailListModel> plist = new ArrayList<ChuchaiDetailListModel>();
		for (int i = 0; i < focs.size(); i++) {
			ChuchaiDetailListModel mt = new ChuchaiDetailListModel();
			Element foc = (Element) focs.get(i);
			if (foc.element("OUName") != null)
				mt.OUName = foc.elementText("OUName");
			if (foc.element("PartnerName") != null)
				mt.PartnerName = foc.elementText("PartnerName");
			if (foc.element("AreaNames") != null)
				mt.AreaNames = foc.elementText("AreaNames");
			if (foc.element("ChuChaiTime") != null)
				mt.ChuChaiTime = foc.elementText("ChuChaiTime");
			if (foc.element("WorkContent") != null)
				mt.WorkContent = foc.elementText("WorkContent");
			plist.add(mt);
		}
		return plist;
	}

}
